using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAL;

namespace BUS
{
    public class tbtinhtrangBUS
    {
        public static void Insert(tbtinhtrangDTO tt)
        {
            tbtinhtrangDAL tbtinhtrangDAL = new tbtinhtrangDAL();
            tbtinhtrangDAL.Insert(tt);
        }
        public static void Update(tbtinhtrangDTO tt)
        {
            tbtinhtrangDAL tbtinhtrangDAL = new tbtinhtrangDAL();
            tbtinhtrangDAL.Update(tt);
        }
        public static void Delete(int iD)
        {
            tbtinhtrangDAL tbtinhtrangDAL = new tbtinhtrangDAL();
            tbtinhtrangDAL.Delete(iD);
        }
        public static tbtinhtrangDTOColection GET(string Where, int PageIndex, int PageSize,
                                        string OrderBy, string OrderDirection,
                                        out int TotalRecords)
        {
            tbtinhtrangDAL tbtinhtrangDAL = new tbtinhtrangDAL();
            return tbtinhtrangDAL.GET(Where, PageIndex, PageSize,
                            OrderBy, OrderDirection, out TotalRecords);
        }
        public static tbtinhtrangDTO GetByID(int iD)
        {
            int t = 0;
            tbtinhtrangDAL tbtinhtrangDAL = new tbtinhtrangDAL();
            tbtinhtrangDTOColection cvcolect = tbtinhtrangDAL.GET("where " + tbtinhtrangDTOColumn.Matinhtrang.ToString() + " = " + iD.ToString(), 0, 0,
                tbtinhtrangDTOColumn.Tentinhtrang.ToString(), "ASC", out t);
            if (cvcolect.Count <= 1)
                return cvcolect[0];
            return null;
        }
        public static tbtinhtrangDTOColection GETAll()
        {
            int t = 0;
            tbtinhtrangDAL tbtinhtrangDAL = new tbtinhtrangDAL();
            return tbtinhtrangDAL.GET("where 1=1", 0, 10, tbtinhtrangDTOColumn.Tentinhtrang.ToString(), "ASC", out t);
        }
    }
}
